package com.xteam.web.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import com.xteam.purview.entities.PurviewFunNode;

public abstract class PurViewController extends MultiActionController implements IController {

	public void setJsonType(HttpServletRequest request, HttpServletResponse response) {
		response.setContentType(JSON_TYPE);
	};

	/**
	 * 对所有模块的主页做跳转
	 * @author tangkf ---2012-2-3
	 * @param request
	 * @param response
	 * @return
	 * @throws Exception
	 */
	public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String url = request.getParameter(PurviewFunNode.PROP_FUNC);
		return new ModelAndView(url);
	}

	/**
	 * @see cn.mystic.web.former.IController#delete(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	public ModelAndView delete(HttpServletRequest request, HttpServletResponse response) throws Exception {
		setJsonType(request, response);
		return null;
	}

	/**
	 * @see cn.mystic.web.former.IController#find(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	public ModelAndView find(HttpServletRequest request, HttpServletResponse response) throws Exception {
		setJsonType(request, response);
		return null;
	}

	/**
	 * @see cn.mystic.web.former.IController#save(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
	 */
	public ModelAndView save(HttpServletRequest request, HttpServletResponse response) throws Exception {
		setJsonType(request, response);
		return null;
	}
}